#!/bin/bash

# 检查是否提供了参数
if [ -z "$1" ]; then
    echo "请提供一个数字作为参数，比如 ./back.sh 1"
    exit 1
fi

# 自定义目标文件夹路径
TARGET_DIR="/mnt/sdb1/zhaoyl/fig_backup/"  # 替换成你的目标文件夹路径

# 根据输入的数字创建对应的文件夹名称
FOLDER_NAME="Fig_$1"

# 创建目标文件夹下的新文件夹
mkdir -p "$TARGET_DIR/$FOLDER_NAME"

# 检查文件是否成功创建
if [ $? -ne 0 ]; then
    echo "创建文件夹失败"
    exit 1
else
    echo "创建文件夹：$TARGET_DIR/$FOLDER_NAME"
fi

# 指定你要备份的文件列表
FILES_TO_BACKUP=(
    "/home/zhaoyl/rdma/multi-ecn/simulation/input/config_dcqcn_test.txt"
    "/home/zhaoyl/rdma/multi-ecn/simulation/input/dc_traffic_test.txt"
    "/home/zhaoyl/rdma/multi-ecn/simulation/output/fct_dcqcn_test.txt"
    "/home/zhaoyl/rdma/multi-ecn/simulation/output/send_rate_dcqcn_test.txt"
    "/home/zhaoyl/rdma/multi-ecn/simulation/img/fig1.pdf"
    "/home/zhaoyl/rdma/multi-ecn/simulation/img/fig1.png"
    "/home/zhaoyl/rdma/multi-ecn/simulation/scripts/plot.py"
)

# 将指定的文件复制到新文件夹
for FILE in "${FILES_TO_BACKUP[@]}"; do
    if [ -f "$FILE" ]; then
        cp "$FILE" "$TARGET_DIR/$FOLDER_NAME/"
        echo "已复制文件：$FILE"
    else
        echo "文件不存在：$FILE"
    fi
done

echo "备份完成"
